package cn.jg.framework.auth.model;

import cn.jg.framework.common.model.SimpleBaseMultiTenantModel;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(value = JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Role extends SimpleBaseMultiTenantModel {

	private static final long serialVersionUID = 1L;

	private String name;

	private Integer type = Type.NORMAL.getValue();

	//	private List<Menu> menuList = Lists.newArrayList();

//	private List<Menu> allMenuList = Lists.newArrayList();

	public boolean isSuperAdmin() {
		return null != this.type && this.type.equals(Type.SUPER_ADMIN.getValue());
	}

	public boolean isAdmin() {
		return null != this.type && (this.type.equals(Type.ADMIN.getValue()) || this.type.equals(Type.SUPER_ADMIN.getValue()));
	}

	public boolean isNormal() {
		return null != this.type && this.type.equals(Type.NORMAL.getValue());
	}

	public enum Type {
		SUPER_ADMIN(1), ADMIN(2), NORMAL(3);
		private int value;

		Type(int value) {
			this.value = value;
		}

		public int getValue() {
			return value;
		}
	}


}